package cn.itcast.order.remote;

import com.alibaba.fastjson.JSONObject;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserApiFallbackFactory implements FallbackFactory<UserApi> {

    @Override
    public UserApi create(Throwable cause) {
        // 返回一个 UserApi 的降级实现
        return new UserApi() {
            @Override
            public String saveUser(JSONObject jsonObject) {
                // 降级处理逻辑
                return "User service is temporarily unavailable. Please try again later.";
            }
        };
    }
}
